import Vue from 'vue'
import Router from 'vue-router' //导入路由器模块
import Home from '@/views/home/Home.vue'

Vue.use(Router)

export default new Router({
	//路由数据  (路由字典)
	routes: [{ //定义重定向路由
			path: "/",
			redirect: "/home",
			meta: {
				title: "首页",
			}
		},
		{ //定义根路由器
			path: '/home', //路由的路径
			name: 'home', //路由的名字
			component: Home, //路由组件(页面组件，带有一定的功能)
			meta: {
				title: "首页",
				alive: true,
			}
		},
		{ //定义商品列表的路由
			path: '/product',
			name: 'product',
			// route level code-splitting
			// this generates a separate chunk (about.[hash].js) for this route
			// which is lazy-loaded when the route is visited.
			component: () => import( /* webpackChunkName: "product" */ '@/views/product/Product.vue'),
			meta: {
				title: "商品",
				alive: true,
			}
		},
		{ //定义商品详情的路由
			path: '/product/detail/:id',
			name: 'productDetail',
			// route level code-splitting
			// this generates a separate chunk (about.[hash].js) for this route
			// which is lazy-loaded when the route is visited.
			component: () => import( /* webpackChunkName: "product" */ '@/views/product/ProductDetail.vue'),
			meta: {
				title: "商品详情",
			}
		},
		{ //定义购物车路由
			path: "/shopcart",
			component: () => import( /* webpackChunkName: "shopcart" */ "@/views/shopcart/Shopcart.vue"),
			name: "shopcart",
			meta: {
				title: "购物车",
				alive: true, //是否缓存
				requireAuth: true, //这个路由需要认证
			},
		},
		{ //定义用户路由
			path: "/user",
			component: () => import("@/views/user/User.vue"),
			name: "user",
			meta: {
				title: "我的",
				alive: true,
			}
		},

		{ //定义登录路由
			path: "/login",
			component: () => import("@/views/user/Login.vue"),
			name: "login",
			meta: {
				title: "登录",
			}
		},
		{ //定义注册路由
			path: "/register",
			component: () => import("@/views/user/Register.vue"),
			name: "register",
			meta: {
				title: "注册",
			}
		},
		{ //定义个人资料路由
			path: "/profile",
			component: () => import("@/views/user/Profile.vue"),
			name: "profile",
			meta: {
				title: "个人资料"
			}
		},
		{ //定义修改密码路由
			path: "/updatePwd",
			component: () => import("@/views/user/UpdatePwd.vue"),
			name: "updatePwd",
			meta: {
				title: "修改密码"
			}
		},
		{ //定义订单创建路由
			path: "/order/create",
			component: () => import("@/views/order/OrderCreate.vue"),
			name: "orderCreate",
			meta: {
				title: "新建订单"
			}
		},
		{ //定义地址列表路由
			path: "/address/list",
			component: () => import("@/views/address/AddressList.vue"),
			name: "addressList",
			meta: {
				title: "地址列表",
				requireAuth: true
			}
		},
		{
			path: "/addressEdit/:id",
			component: () => import("@/views/address/AddressEdit.vue"),
			props: true,
			name: "addressEdit",
			meta: {
				title: "收货地址",
				requireAuth: true
			},
		},
		{ //定义订单列表路由
			path: "/order/list",
			component: () => import("@/views/order/OrderList.vue"),
			name: "orderList",
			meta: {
				title: "订单列表",
				requireAuth: true
			},
		},
		{
			path: "/order/detail/:id",
			component: () => import("@/views/order/OrderDetail.vue"),
			props: true,
			name: "orderDetail",
			meta: {
				title: "收订单详情",
				requireAuth: true
			},
		},
		{ //定义新闻列表路由
			path: '/news/list',
			name: 'newsList',
			component: () => import( /* webpackChunkName: "news" */ '@/views/news/NewsList.vue'),
			meta: {
				title: "新闻列表",
			}
		},
		{ //定义新闻详情路由
			path: '/news/detail/:id', //动态路由参数
			props: true, //允许props接收
			name: 'newsDetail',
			component: () => import( /* webpackChunkName: "news" */ '@/views/news/NewsDetail.vue'),
			meta: {
				title: "新闻详情",
			}
		},
		{
			path: "/photo/list",
			component: () => import("@/views/photo/PhotoList.vue"),
			name: "photoList",
			meta: {
				title: "图片分享列表"
			},
		},
		{
			path: "/photo/detail/:id",
			component: () => import("@/views/photo/PhotoDetail.vue"),
			props: true,
			name: "photoDetail",
			meta: {
				title: "查看图片"
			},
		},
		{ //定义咨询记录路由
			path: '/contact/list',
			name: 'contactList',
			component: () => import( /* webpackChunkName: "contact" */ '@/views/contact/ContactList.vue'),
			meta: {
				title: "咨询记录"
			}
		},
		{ //定义咨询详情路由
			path: '/contact/edit/:id', //动态路由参数
			props: true, //允许props接收
			name: 'contactEdit',
			component: () => import( /* webpackChunkName: "contact" */ '@/views/contact/ContactEdit.vue'),
			meta: {
				title: "咨询详情"
			}
		},
		{
			path: "/working",
			component: () => import("@/views/Working.vue"),
			name: "working",
			meta: {
				title: "努力中...."
			},
		},
		{
			path: "*",
			name: "notFound",
			component: () => import( /* webpackChunkName: "notfound" */ '@/views/NotFound.vue'),
			meta: {
				title: "导航页面不存在"
			},
		},
		{ //定义todo案例路由
			path: "/todo",
			component: () => import("@/views/todo/Todo.vue"),
			name: "todo",
			meta: {
				title: "TODO案例"
			},
		},
	]
})
